Fix search failure on user index due to nested owners query#26794
Fix search failure on user index due to nested owners query#26794sonika-shah wants to merge 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes search failures when RBAC injects owners nested queries against indexes where owners is not mapped as a nested field by adding ignore_unmapped=true to nested queries (Elasticsearch + OpenSearch), with accompanying test coverage.
Changes:
- Add
ignore_unmappedto nested query builders for Elasticsearch and OpenSearch. - Add
ignore_unmappedto JSON-based nested query filters (e.g., owners filters) and assert it in unit tests. - Re-enable a previously skipped Playwright E2E test related to notification alerts.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/NotificationAlerts.spec.ts | Unskips an alerts permissions E2E flow. |
| openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/queries/OpenSearchQueryBuilder.java | Sets ignoreUnmapped(true) on nested queries built via the OpenSearch query builder. |
| openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/OpenSearchQueryBuilder.java | Sets ignoreUnmapped(true) on the static OpenSearch nested query helper. |
| openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/queries/ElasticQueryBuilder.java | Sets ignoreUnmapped(true) on nested queries built via the Elasticsearch query builder. |
| openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/ElasticQueryBuilder.java | Sets ignoreUnmapped(true) on the static Elasticsearch nested query helper. |
| openmetadata-service/src/main/java/org/openmetadata/service/search/SearchListFilter.java | Adds ignore_unmapped:true to the owners nested filter JSON. |
| openmetadata-service/src/main/java/org/openmetadata/service/search/QueryFilterBuilder.java | Adds ignore_unmapped:true to nested query JSON generated by filter builder helpers. |
| openmetadata-service/src/test/java/org/openmetadata/service/search/security/OpenSearchRBACConditionEvaluatorTest.java | Adds tests asserting nested query JSON includes ignore_unmapped:true (OpenSearch). |
| openmetadata-service/src/test/java/org/openmetadata/service/search/security/ElasticSearchRBACConditionEvaluatorTest.java | Adds tests asserting nested query JSON includes ignore_unmapped:true (Elasticsearch). |
| openmetadata-service/src/test/java/org/openmetadata/service/search/QueryFilterBuilderTest.java | Asserts ignore_unmapped is present in nested filters and adds additional nested-query structure checks. |
| openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/SearchListFilterTest.java | Asserts ignore_unmapped is present in owners nested filters and updates expected serialized content. |
openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/NotificationAlerts.spec.ts
Show resolved
Hide resolved
...src/main/java/org/openmetadata/service/search/opensearch/queries/OpenSearchQueryBuilder.java
Show resolved
Hide resolved
OpenMetadata Service New-Code Coverage✅ PASS. Required changed-line coverage:
Only changed executable lines under |
|
🟡 Playwright Results — all passed (24 flaky)✅ 3392 passed · ❌ 0 failed · 🟡 24 flaky · ⏭️ 216 skipped
🟡 24 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Code Review ✅ ApprovedFixes search failure on the user index caused by nested owners query by ignoring unmapped fields. No issues found. OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
| private String getOwnerCondition() { | ||
| String owners = getQueryParam("owners"); | ||
| if (!nullOrEmpty(owners)) { | ||
| String ownersList = | ||
| Arrays.stream(owners.split(",")).collect(Collectors.joining("\", \"", "\"", "\"")); | ||
| return String.format( | ||
| "{\"nested\":{\"path\":\"owners\",\"query\":{\"terms\":{\"owners.id\":[%s]}}}}", | ||
| "{\"nested\":{\"path\":\"owners\",\"query\":{\"terms\":{\"owners.id\":[%s]}},\"ignore_unmapped\":true}}", | ||
| ownersList); | ||
| } |
There was a problem hiding this comment.
PR description says to add ignore_unmapped=true to all nested queries, but in this class only the owners nested query was updated. There are other nested query JSON snippets built here (e.g., tags and testSuites) that still omit ignore_unmapped, so similar unmapped-field failures could still occur and the change is inconsistent with the stated intent. Consider adding ignore_unmapped to those nested clauses as well (and updating tests accordingly).
|



Describe your changes:
Fixes #3280
The RBAC layer unconditionally adds nested owners queries to all search
requests. Indexes like user that don't have owners as a nested field
fail with "failed to find nested object under path [owners]".
Add ignore_unmapped=true to all nested queries so they gracefully return
no matches on indexes without the nested field instead of throwing 500.
Type of change:
Checklist:
Fixes <issue-number>: <short explanation>